<template>
  <div class="Mine">
    <div class="banner">
      <div class="user_card">
        <div class="top" v-if="this.$route.meta.auth">
          <img :src="MineData.avatar" class="avatar" />
          <div class="info">
            <div class="nickname">{{ MineData.nickname }}</div>
            <div class="phone">
              {{ MineData.phone }}
              <i class="fa fa-pencil"></i>
            </div>
          </div>
        </div>
        <div class="top" v-if="!this.$route.meta.auth">
          <img
            src="https://java.crmeb.net/static/images/f.png"
            class="avatar"
          />
          <div class="info">
            <div class="nickname" @click="login">请点击登录</div>
          </div>
        </div>
        <div class="bot" v-if="this.$route.meta.auth">
          <div class="item">
            <span>
              {{ MineData.brokeragePrice }}
            </span>
            <p>余额</p>
          </div>
          <div class="item">
            <span>
              {{ MineData.integral }}
            </span>
            <p>积分</p>
          </div>
          <div class="item">
            <span>{{ MineData.couponCount }}</span>
            <p>优惠劵</p>
          </div>
          <div class="item">
            <span>
              {{ MineData.collectCount }}
            </span>
            <p>收藏</p>
          </div>
        </div>
        <div class="bot" v-if="!this.$route.meta.auth">
          <div class="item">
            <span> 0 </span>
            <p>余额</p>
          </div>
          <div class="item">
            <span> 0 </span>
            <p>积分</p>
          </div>
          <div class="item">
            <span>0</span>
            <p>优惠劵</p>
          </div>
          <div class="item">
            <span> 0 </span>
            <p>收藏</p>
          </div>
        </div>
      </div>
      <div class="order">
        <div class="order_tit">
          <h3 class="name">订单中心</h3>
          <span class="all"
            >查看更多
            <van-icon name="arrow" />
          </span>
        </div>
        <div class="conter">
          <div class="item">
            <van-icon name="paid" />
            <span>待付款</span>
          </div>
          <div class="item">
            <van-icon name="logistics" />
            <span>待发货</span>
          </div>
          <div class="item">
            <van-icon name="send-gift" />
            <span>待收货</span>
          </div>
          <div class="item">
            <i class="fa fa-comments-o"></i>
            <span>待评价</span>
          </div>
          <div class="item">
            <van-icon name="refund-o" />
            <span>售后/退款</span>
          </div>
        </div>
      </div>
      <div class="serve">
        <h3 class="name">我的服务</h3>
        <div class="serve_conter" v-if="this.$route.meta.auth">
          <div class="conter_item" v-for="item in servelist" :key="item.id">
            <img :src="item.pic" alt="" />
            <span>{{ item.name }}</span>
          </div>
        </div>
        <div class="serve_conter" v-if="!this.$route.meta.auth">
          <div class="conter_item">
            <img
              src="https://java.crmeb.net/static/images/customer.png"
              alt=""
            />
            <span>联系客服</span>
          </div>
        </div>
      </div>
      <img
        src="https://java.crmeb.net/static/images/support.png"
        alt=""
        class="icon_pic"
      />
    </div>
  </div>
</template>

<script>
export default {
  name: "FxhDemoMineView",

  data() {
    return {
      MineData: [],
      servelist: [],
    };
  },
  async created() {
    localStorage.getItem("token")
      ? (this.$route.meta.auth = true)
      : (this.$route.meta.auth = false);
    if (this.$route.meta.auth) {
      const {
        data: { data },
      } = await this.$request("get", "/fxh/user");
      // console.log(data);
      this.MineData = data;
      console.log(this.MineData);
      const serve = await this.$request("get", "/fxh/menu/user");
      this.servelist = serve.data.data.routine_my_menus;
    }
  },

  mounted() {},

  methods: {
    login() {
      this.$router.push("/Login?redirect=/Mine");
    },
  },
};
</script>

<style lang="scss" scoped>
.Mine {
  width: 375px;
  height: 87vh;
  margin-bottom: 30vh;
  .banner {
    width: 375px;
    height: 40vh;
    background: -webkit-linear-gradient(270deg, #ff448f, #f5f5f5);
    padding-top: 10px;
  }
  .user_card {
    @include cloumn;
    justify-content: space-between;
    width: 347px;
    height: 18vh;
    margin: 13px;
    .top {
      @include flex;
      .avatar {
        width: 59px;
        height: 59px;
        border-radius: 50%;
      }
      .nickname {
        align-items: center;
        color: #fff;
        height: 19px;
        margin: 7px;
        font-size: 15px;
        line-height: 19px;
      }
      .phone {
        padding-left: 10px;
        font-size: 12px;
        color: hsla(0, 0%, 100%, 0.6);
      }
    }
    .bot {
      width: 347px;
      display: flex;
      justify-content: space-around;
      .item {
        @include cloumn-center;
        width: 86px;
        height: 44px;
        span {
          font-size: 20px;
          font-weight: 700;
          color: #fff;
        }
        p {
          font-size: 12px;
          color: #f5f5f5;
        }
      }
    }
  }
  .order {
    width: 347px;
    height: 112px;
    background: #fff;
    border-radius: 5px;
    margin-left: 15px;
    .order_tit {
      padding: 10px;
      @include between;
      .name {
        color: #282828;
        font-size: 14px;
        font-weight: 600;
      }
      .all {
        align-items: center;
        color: #666;
        font-size: 12px;
      }
    }
    .conter {
      @include around;
      .item {
        @include cloumn-center;
        margin-top: 20px;
        .van-icon {
          width: 23px;
          height: 23px;
          font-size: 23px;
          color: #ff448f !important;
        }
        .fa-comments-o {
          width: 23px;
          height: 23px;
          font-size: 23px;
          color: #ff448f !important;
        }
        span {
          margin-top: 7px;
          font-size: 12px;
          color: #454545;
        }
      }
    }
  }
  .serve {
    width: 347px;
    height: 335px;
    background: white;
    margin-top: 10px;
    margin-left: 15px;
    .name {
      padding: 14px 14px 19px;
      font-size: 14px;
      color: #282828;
      font-weight: 600;
    }
    .serve_conter {
      @include flex;
      flex-wrap: wrap;
      height: 284px;

      .conter_item {
        width: 86px;
        height: 48px;
        @include cloumn-center;
        > img {
          width: 25px;
          height: 25px;
        }
        > span {
          font-size: 12px;
          color: #333;
        }
      }
    }
  }
  .icon_pic {
    width: 109px;
    height: 36px;
    margin-left: 130px;
    margin-top: 8vh;
  }
}
</style>
